import { createBrowserRouter } from "react-router";
import RootLayout from "@/layouts/RootLayout";
import componentRoutes from "./components";
import DemoPage from "./demo";
import DomDemoPage from "./demo/dom";
import ErrorDemoPage from "./demo/error";
import JokePage from "./demo/joke";
import LoaderDemoPage, { demoLoader } from "./demo/load-data";
import HomePage from "./HomePage";
import LoginPage from "./login";

// Create a new router instance
export default createBrowserRouter([
  {
    path: "/",
    Component: RootLayout,
    children: [
      { index: true, Component: HomePage },
      { path: "login", Component: LoginPage },
      componentRoutes,
      {
        path: "demo",
        children: [
          { index: true, Component: DemoPage },
          { path: "dom", Component: DomDemoPage },
          { path: "error", Component: ErrorDemoPage },
          { path: "joke", Component: JokePage },
          { path: "load-data", Component: LoaderDemoPage, loader: demoLoader },
        ],
      },
    ],
  },
]);
